<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
        "http://www.w3.org/TR/html4/loose.dtd">
<!--[if IE 8]>
<html lang="en" class="ie8 no-js"> <![endif]-->
<!--[if IE 9]>
<html lang="en" class="ie9 no-js"> <![endif]-->
<!--[if !IE]><!-->
<html lang="en" class="no-js"> <!--<![endif]-->
<!-- BEGIN HEAD -->
<head>
    <include file="Public:meta"/>
    <link rel="stylesheet" type="text/css" href="__TMPL__Public/plugins/bootstrap-fileupload/bootstrap-fileupload.css"/>
    <link rel="stylesheet" type="text/css" href="__TMPL__Public/css/goods.css"/>
</head>
<!-- END HEAD -->
<!-- BEGIN BODY -->
<body class="page-header-fixed">
<include file="Public:header"/>
<!-- BEGIN CONTAINER -->
<div class="page-container">
    <include file="Public:sidebar"/>
    <!-- BEGIN PAGE -->
    <div class="page-content">
        <div class="container-fluid">
            <div class="row-fluid">
                <!-- begin BCN -->
                <div class="row-fluid">
                    <div class="span12"><ul class="breadcrumb"><li><a onfocus="blurLink(this);" href="{:U(CONTROLLER_NAME . '/index', 'kept=1')}">{$ParentPageName|default="未命名"}</a>&nbsp;<span class="icon-angle-right"></span>&nbsp;</li><li>{$PageName|default="未命名"}</li></ul></div>
                </div>
                <!-- end BCN -->
            </div>
            <div class="row-fluid white">
                <div class="span12">
                    <form action="" method="post" class="form-horizontal" enctype="multipart/form-data">
                        {$autoFields}
                        <input type='hidden' name="del_ids" />
                        <div class="form-button">
                            <button type="submit" class="btn blue">保存数据 <i class="icon-save"></i></button>
                            <a href="{:U(CONTROLLER_NAME . '/index', 'kept=1')}" class="btn">返回列表 <i class="icon-share-alt"></i></a>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
    <!-- END PAGE -->
</div>
<include file="Public:footer"/>
<script type="text/javascript" src="__TMPL__Public/plugins/bootstrap-fileupload/bootstrap-fileupload.js"></script>
<script type="text/javascript">
    jQuery(document).ready(function () {
        //动态商品规格
        $('form').on('change','select[name=goods_id]',function(){
            var goods_id = $(this).val();
            var type = $('form input[name=type]:checked').val();
            if(goods_id){
                $.ajax({
                    url:"{:U(CONTROLLER_NAME.'/getGoodsInfo')}",
                    data:{
                        goods_id:goods_id,
                        type:type
                    },
                    type:'POST',
                    dataType:'JSON',
                    success:function(rs){
                        var value = $('form input[name=type][type=radio]:checked').val();
                        if(rs.length){
                            $('form .group_prices').hide(); 
                            $('form .goods_id').append(rs);
                            $('form .leader_prices').hide();
                        }else{
                            $('form .goods_id .ass').remove();
                            $('form .group_prices').show();  
                            if(value == 2){
                                $('form .leader_price').show();
                            }else{
                                $('form .leader_prices').hide();
                            }
                        }
                    }
                })
            }else{
                $('form .goods_id .ass').remove();
                $('form .group_prices').show();
            }   
        });
        init();
        //普通团，精品团切换显示不同的字段
        $('body').on('change','form input[name=type][type=radio]:checked',function(){
            init();
        })
    });
    function init(){
        var value = $('form input[name=type][type=radio]:checked').val();
        if(value == '1'){
            $('.auto_group').show();
            $('.cut_money').show();
            $('.group_coupon_id').hide();
            $('.total').hide();
        }else{
            $('.auto_group').hide();
            $('.cut_money').hide();
            $('.group_coupon_id').show();
            $('.total').show();
        }
        //判断是否选择商品，且选择的商品是否含有多规格
        var flag = $('form .goods_id .ass').length;
        if(flag){
            $('.group_prices').hide();
            $('.leader_prices').hide();
            if(value == '2'){
                var head = '<span class="leader">团长价</span>';
                var body = '<span class="leader"><input name="leader_price[]" type="text" class="setInp"/></span>';
                $('form .tabHead').append(head);
                $('form .propertyTable .item').each(function(){
                    $(this).append(body);
                });
            }else{
                $('form .goods_id .ass .leader').remove();
            }
            $('form .goods_id .ass .propertyTable').toggleClass('group');
        }else{
            $('.group_prices').show();
            if(value == '2'){
                $('.leader_prices').show();
            }else{
                $('.leader_prices').hide();
            }
        }
    }
</script>
<!-- END JAVASCRIPTS -->
</body>
<!-- END BODY -->
</html>